/*
 * @Author: 晟松
 * @Date: 2021-11-30 00:00:42
 * @LastEditors: 晟松
 * @LastEditTime: 2021-12-10 16:16:06
 * @FilePath: \mini-vue3d:\Code\node\koa2\volunteer-service\src\main\common\CommonError.js
 * @Description:
 */
export const COMMON_ERROR_CODE = 500;
export const PARAM_ERROR_CODE = 501;
export const LOGIN_ERROR_CODE = 401;
export const NOTFOUND_ERROR_CODE = 404;

export const IDENTITY_ERROR_CODE = 403;

/**
 * 通用异常
 */
export class CommonError extends Error {
    constructor(code = COMMON_ERROR_CODE, msg = "服务器异常") {
        super();
        this.code = code;
        this.msg = msg;
    }
}

/**
 * 参数异常
 */
export class ParamError extends CommonError {
    constructor(msg = "参数异常") {
        super(PARAM_ERROR_CODE, msg);
    }
}

export class LoginError extends CommonError {
    constructor(msg = "登录异常") {
        super(LOGIN_ERROR_CODE, msg);
    }
}

export class NotFoundError extends CommonError {
    constructor(msg = "not found") {
        super(NOTFOUND_ERROR_CODE, msg);
    }
}

export class IdentityError extends CommonError {
    constructor(msg = "identity error") {
        super(IDENTITY_ERROR_CODE, msg);
    }
}
